﻿<Page x:Class="Microsoft.NodejsTools.Project.ImportWizard.FileSourcePage"
      x:ClassModifier="internal"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:wpf="clr-namespace:Microsoft.VisualStudioTools.Wpf"
      xmlns:l="clr-namespace:Microsoft.NodejsTools.Project.ImportWizard"
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="500"
      Title="Source Files"
      FocusManager.FocusedElement="{Binding ElementName=SourcePathTextBox}">
    <Page.Resources>
        <ResourceDictionary Source="ImportWizardDictionary.xaml" />
    </Page.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        
        <wpf:LabelledControl Title="Choose which file to run when F5 is pressed."
                           HelpText="If it is not in this list, you can right-click any file in your project and choose &quot;Set as startup file&quot;"
                           Grid.Row="0">
            <ListView Name="listView"
                      ItemsSource="{Binding TopLevelJavaScriptFiles}"
                      SelectionMode="Single"
                      SelectedItem="{Binding StartupFile,Mode=TwoWay}"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto"
                      ScrollViewer.VerticalScrollBarVisibility="Disabled">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Vertical" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="1 1 4 1">
                            <Grid>
                                <TextBlock Name="Filename" Text="{Binding}" />
                                <!-- Ensure there is enough space for the bolded version of the text. -->
                                <TextBlock Text="{Binding}" FontWeight="Bold" Visibility="Hidden" />
                            </Grid>
                        </StackPanel>
                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem},Path=IsSelected}" Value="True">
                                <Setter TargetName="Filename" Property="FontWeight" Value="Bold" />
                            </DataTrigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </wpf:LabelledControl>
        
        <wpf:LabelledControl Title="Select any other options for your project."
                           Grid.Row="1">
            <StackPanel Orientation="Vertical">
                <CheckBox IsChecked="{Binding ExcludeNodeModules}">Exclude node__modules</CheckBox>
            </StackPanel>
        </wpf:LabelledControl>
    </Grid>
</Page>
